%% User typeface 
% by Jaromir Benes
%
% This m-file illustrates the use of the option `'typeface'`. The option
% can be specified for some of the first-level elements, and allows to add
% LaTeX commands before that elements that will be applied to it and change
% possible its appearance (such as font size).

%% Clear Workspace

clear;
close all;
home;
irisrequired 8.20111122;

%% Create artificial data for the report

range = qq(2010,1) : qq(2012,4);

d = struct();
d.x = tseries(range,@rand);
d.y = tseries(range,@rand);
d.z = tseries(range,@rand);

%% Start new report

x = report.new('');

%% Create table with no user formatting added
%
% This is just a plain table against which you can compare the other ones,
% with user formatting added.

x.table({'My first table','Default typeface'}, ...
    'range=',range,'dateformat=','YYYY:P');
x.series('X',d.x);
x.series('Y',d.y);
x.series('Z',d.z);

x.pagebreak();

%% Create table with font size set to Large
%
% We first create a table <?titlenotfixed?> with font size set to
% `'\Large'` right before the table starts. Because the table title itself
% is, by default, formatted as `'\large\bfseries'` it will be typeset
% smaller than the rest of the table.
%
% We fix this in the other table on this page, <?titlefixed?> where we
% manually set the `'captioformat'` option for the title and subtitle. Note
% that the `'captionformat'` option is specified as a 1-by-2 cell array of
% strings, with the first string used to format the title, and the other
% used to format the subtitle.

x.table({'My second table','Large font size'}, ...
    'range=',range,'dateformat=','YYYY:P', ...
    'typeface=','\Large'); %?titlenotfixed?
x.series('X',d.x);
x.series('Y',d.y);
x.series('Z',d.z);

x.table({'My second table','Large font size with the title size fixed'}, ...
    'range=',range,'dateformat=','YYYY:P', ...
    'typeface=','\Large', ...
    'captiontypeface=',{'\LARGE\bfseries','\Large'}); %?titlefixed?
x.series('X',d.x);
x.series('Y',d.y);
x.series('Z',d.z);

x.pagebreak();

%% Create table with font size set to footnotesize and color to red
%
% We do the same as before, now decreasing the font size to `footnotesize`
% and changing the text color to red. At the same time, we also manually
% fix the font size for the title and subtitle.

x.table({'My third table','Footnote font size, red colour'}, ...
    'range=',range,'dateformat=','YYYY:P', ...
    'typeface=','\footnotesize\color{red}', ...
    'captiontypeface=',{'\normalsize\bfseries','\footnotesize'});
x.series('X',d.x);
x.series('Y',d.y);
x.series('Z',d.z);

%% Publish report to PDF
%
% Compile the report into a PDF named `'report_user_latex_formats.pdf'`.
% The `open` command the PDF <?open?> may not work on some systems.

x.publish('report_user_typeface.pdf');

open report_user_typeface.pdf; %?open?

%% Help on IRIS functions used in this m-file
%
% Use either `help` to display help in the command window, or `idoc`
% to display help in an HTML browser window.
%
%    help report
%    help report/new
%    help report/table
%    help report/series
%    help report/publish
%    help dates/qq
%    help tseries
%    help tseries/tseries
